<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- qtextformat.cpp -->
  <title>QTextTableFormat Class | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QTextTableFormat</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QTextTableFormat Class</h1>
<!-- $$$QTextTableFormat-brief -->
<p>The QTextTableFormat class provides formatting information for tables in a <a href="qtextdocument.html">QTextDocument</a>. <a href="#details">More...</a></p>
<!-- @@@QTextTableFormat -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QTextTableFormat&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qtextframeformat.html">QTextFrameFormat</a></td></tr></table></div><ul>
<li><a href="qtexttableformat-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are <a href="../qtdoc/threads-reentrancy.html">reentrant</a>.</p>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#QTextTableFormat">QTextTableFormat</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::Alignment </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#alignment">alignment</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#borderCollapse">borderCollapse</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#cellPadding">cellPadding</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#cellSpacing">cellSpacing</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#clearColumnWidthConstraints">clearColumnWidthConstraints</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector&lt;QTextLength&gt; </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#columnWidthConstraints">columnWidthConstraints</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#columns">columns</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#headerRowCount">headerRowCount</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#isValid">isValid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setAlignment">setAlignment</a></b>(Qt::Alignment <i>alignment</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setBorderCollapse">setBorderCollapse</a></b>(bool <i>borderCollapse</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setCellPadding">setCellPadding</a></b>(qreal <i>padding</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setCellSpacing">setCellSpacing</a></b>(qreal <i>spacing</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setColumnWidthConstraints">setColumnWidthConstraints</a></b>(const QVector&lt;QTextLength&gt; &amp;<i>constraints</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qtexttableformat.html#setHeaderRowCount">setHeaderRowCount</a></b>(int <i>count</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QTextTableFormat-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>A table is a group of cells ordered into rows and columns. Each table contains at least one row and one column. Each cell contains a block. Tables in rich text documents are formatted using the properties defined in this class.</p>
<p>Tables are horizontally justified within their parent frame according to the table's alignment. This can be read with the <a href="qtexttableformat.html#alignment">alignment</a>() function and set with <a href="qtexttableformat.html#setAlignment">setAlignment</a>().</p>
<p>Cells within the table are separated by cell spacing. The number of pixels between cells is set with <a href="qtexttableformat.html#setCellSpacing">setCellSpacing</a>() and read with <a href="qtexttableformat.html#cellSpacing">cellSpacing</a>(). The contents of each cell is surrounded by cell padding. The number of pixels between each cell edge and its contents is set with <a href="qtexttableformat.html#setCellPadding">setCellPadding</a>() and read with <a href="qtexttableformat.html#cellPadding">cellPadding</a>().</p>
<p class="centerAlign"><img src="images/qtexttableformat-cell.png" alt="" /></p><p>The table's background color can be read with the <a href="qtextformat.html#background">background</a>() function, and can be specified with <a href="qtextformat.html#setBackground">setBackground</a>(). The background color of each cell can be set independently, and will control the color of the cell within the padded area.</p>
<p>The table format also provides a way to constrain the widths of the columns in the table. Columns can be assigned a fixed width, a variable width, or a percentage of the available width (see <a href="qtextlength.html">QTextLength</a>). The <a href="qtexttableformat.html#columns">columns</a>() function returns the number of columns with constraints, and the <a href="qtexttableformat.html#columnWidthConstraints">columnWidthConstraints</a>() function returns the constraints defined for the table. These quantities can also be set by calling <a href="qtexttableformat.html#setColumnWidthConstraints">setColumnWidthConstraints</a>() with a vector containing new constraints. If no constraints are required, <a href="qtexttableformat.html#clearColumnWidthConstraints">clearColumnWidthConstraints</a>() can be used to remove them.</p>
</div>
<p><b>See also </b><a href="qtexttable.html">QTextTable</a>, <a href="qtexttablecell.html">QTextTableCell</a>, and <a href="qtextlength.html">QTextLength</a>.</p>
<!-- @@@QTextTableFormat -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QTextTableFormat[overload1]$$$QTextTableFormat -->
<h3 class="fn" id="QTextTableFormat"><a name="QTextTableFormat"></a>QTextTableFormat::<span class="name">QTextTableFormat</span>()</h3>
<p>Constructs a new table format object.</p>
<!-- @@@QTextTableFormat -->
<!-- $$$alignment[overload1]$$$alignment -->
<h3 class="fn" id="alignment"><a name="alignment"></a><span class="type"><a href="../qtcore/qt.html#AlignmentFlag-enum">Qt::Alignment</a></span> QTextTableFormat::<span class="name">alignment</span>() const</h3>
<p>Returns the table's alignment.</p>
<p><b>See also </b><a href="qtexttableformat.html#setAlignment">setAlignment</a>().</p>
<!-- @@@alignment -->
<!-- $$$borderCollapse[overload1]$$$borderCollapse -->
<h3 class="fn" id="borderCollapse"><a name="borderCollapse"></a><span class="type">bool</span> QTextTableFormat::<span class="name">borderCollapse</span>() const</h3>
<p>Returns true if borderCollapse is enabled.</p>
<p>This function was introduced in Qt 5.14.</p>
<p><b>See also </b><a href="qtexttableformat.html#setBorderCollapse">setBorderCollapse</a>().</p>
<!-- @@@borderCollapse -->
<!-- $$$cellPadding[overload1]$$$cellPadding -->
<h3 class="fn" id="cellPadding"><a name="cellPadding"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QTextTableFormat::<span class="name">cellPadding</span>() const</h3>
<p>Returns the table's cell padding. This describes the distance between the border of a cell and its contents.</p>
<p><b>See also </b><a href="qtexttableformat.html#setCellPadding">setCellPadding</a>().</p>
<!-- @@@cellPadding -->
<!-- $$$cellSpacing[overload1]$$$cellSpacing -->
<h3 class="fn" id="cellSpacing"><a name="cellSpacing"></a><span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> QTextTableFormat::<span class="name">cellSpacing</span>() const</h3>
<p>Returns the table's cell spacing. This describes the distance between adjacent cells.</p>
<p><b>See also </b><a href="qtexttableformat.html#setCellSpacing">setCellSpacing</a>().</p>
<!-- @@@cellSpacing -->
<!-- $$$clearColumnWidthConstraints[overload1]$$$clearColumnWidthConstraints -->
<h3 class="fn" id="clearColumnWidthConstraints"><a name="clearColumnWidthConstraints"></a><span class="type">void</span> QTextTableFormat::<span class="name">clearColumnWidthConstraints</span>()</h3>
<p>Clears the column width constraints for the table.</p>
<p><b>See also </b><a href="qtexttableformat.html#columnWidthConstraints">columnWidthConstraints</a>() and <a href="qtexttableformat.html#setColumnWidthConstraints">setColumnWidthConstraints</a>().</p>
<!-- @@@clearColumnWidthConstraints -->
<!-- $$$columnWidthConstraints[overload1]$$$columnWidthConstraints -->
<h3 class="fn" id="columnWidthConstraints"><a name="columnWidthConstraints"></a><span class="type"><a href="../qtcore/qvector.html">QVector</a></span>&lt;<span class="type"><a href="qtextlength.html">QTextLength</a></span>&gt; QTextTableFormat::<span class="name">columnWidthConstraints</span>() const</h3>
<p>Returns a list of constraints used by this table format to control the appearance of columns in a table.</p>
<p><b>See also </b><a href="qtexttableformat.html#setColumnWidthConstraints">setColumnWidthConstraints</a>().</p>
<!-- @@@columnWidthConstraints -->
<!-- $$$columns[overload1]$$$columns -->
<h3 class="fn" id="columns"><a name="columns"></a><span class="type">int</span> QTextTableFormat::<span class="name">columns</span>() const</h3>
<p>Returns the number of columns specified by the table format.</p>
<!-- @@@columns -->
<!-- $$$headerRowCount[overload1]$$$headerRowCount -->
<h3 class="fn" id="headerRowCount"><a name="headerRowCount"></a><span class="type">int</span> QTextTableFormat::<span class="name">headerRowCount</span>() const</h3>
<p>Returns the number of rows in the table that define the header.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qtexttableformat.html#setHeaderRowCount">setHeaderRowCount</a>().</p>
<!-- @@@headerRowCount -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QTextTableFormat::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if this table format is valid; otherwise returns <code>false</code>.</p>
<!-- @@@isValid -->
<!-- $$$setAlignment[overload1]$$$setAlignmentQt::Alignment -->
<h3 class="fn" id="setAlignment"><a name="setAlignment"></a><span class="type">void</span> QTextTableFormat::<span class="name">setAlignment</span>(<span class="type"><a href="../qtcore/qt.html#AlignmentFlag-enum">Qt::Alignment</a></span> <i>alignment</i>)</h3>
<p>Sets the table's <i>alignment</i>.</p>
<p><b>See also </b><a href="qtexttableformat.html#alignment">alignment</a>().</p>
<!-- @@@setAlignment -->
<!-- $$$setBorderCollapse[overload1]$$$setBorderCollapsebool -->
<h3 class="fn" id="setBorderCollapse"><a name="setBorderCollapse"></a><span class="type">void</span> QTextTableFormat::<span class="name">setBorderCollapse</span>(<span class="type">bool</span> <i>borderCollapse</i>)</h3>
<p>Enabling <i>borderCollapse</i> will have the following implications:</p>
<ul>
<li>The borders and grid of the table will be rendered following the CSS table <code>border-collapse</code>: <code>collapse</code> rules</li>
<li>Setting the <code>border</code> property to a minimum value of <code>1</code> will render a one pixel solid inner table grid using the <a href="qtextframeformat.html#borderBrush">borderBrush</a> property and an outer border as specified</li>
<li>The various border style properties of <a href="qtexttablecellformat.html">QTextTableCellFormat</a> can be used to customize the grid and have precedence over the border and grid of the table</li>
<li>The <a href="qtexttableformat.html#cellSpacing">cellSpacing</a> property will be ignored</li>
<li>For print pagination:<ul>
<li>Columns continued on a page will not have their top cell border rendered</li>
<li>Repeated header rows will always have their bottom cell border rendered</li>
</ul>
</li>
</ul>
<p>With <a href="qtexttableformat.html#borderCollapse">borderCollapse</a> disabled, cell borders can still be styled using <a href="qtexttablecellformat.html">QTextTableCellFormat</a> but styling will be applied only within the cell's frame, which is probably not very useful in practice.</p>
<p>This function was introduced in Qt 5.14.</p>
<p><b>See also </b><a href="qtexttableformat.html#borderCollapse">borderCollapse</a>(), <a href="qtextframeformat.html#setBorder">setBorder</a>(), <a href="qtextframeformat.html#setBorderBrush">setBorderBrush</a>(), <a href="qtextframeformat.html#setBorderStyle">setBorderStyle</a>(), and <a href="qtexttablecellformat.html">QTextTableCellFormat</a>.</p>
<!-- @@@setBorderCollapse -->
<!-- $$$setCellPadding[overload1]$$$setCellPaddingqreal -->
<h3 class="fn" id="setCellPadding"><a name="setCellPadding"></a><span class="type">void</span> QTextTableFormat::<span class="name">setCellPadding</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>padding</i>)</h3>
<p>Sets the cell <i>padding</i> for the table. This determines the distance between the border of a cell and its contents.</p>
<p><b>See also </b><a href="qtexttableformat.html#cellPadding">cellPadding</a>().</p>
<!-- @@@setCellPadding -->
<!-- $$$setCellSpacing[overload1]$$$setCellSpacingqreal -->
<h3 class="fn" id="setCellSpacing"><a name="setCellSpacing"></a><span class="type">void</span> QTextTableFormat::<span class="name">setCellSpacing</span>(<span class="type"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></span> <i>spacing</i>)</h3>
<p>Sets the cell <i>spacing</i> for the table. This determines the distance between adjacent cells.</p>
<p>This property will be ignored if <a href="qtexttableformat.html#borderCollapse">borderCollapse</a> is enabled.</p>
<p><b>See also </b><a href="qtexttableformat.html#cellSpacing">cellSpacing</a>().</p>
<!-- @@@setCellSpacing -->
<!-- $$$setColumnWidthConstraints[overload1]$$$setColumnWidthConstraintsconstQVector<QTextLength>& -->
<h3 class="fn" id="setColumnWidthConstraints"><a name="setColumnWidthConstraints"></a><span class="type">void</span> QTextTableFormat::<span class="name">setColumnWidthConstraints</span>(const <span class="type"><a href="../qtcore/qvector.html">QVector</a></span>&lt;<span class="type"><a href="qtextlength.html">QTextLength</a></span>&gt; &amp;<i>constraints</i>)</h3>
<p>Sets the column width <i>constraints</i> for the table.</p>
<p><b>See also </b><a href="qtexttableformat.html#columnWidthConstraints">columnWidthConstraints</a>() and <a href="qtexttableformat.html#clearColumnWidthConstraints">clearColumnWidthConstraints</a>().</p>
<!-- @@@setColumnWidthConstraints -->
<!-- $$$setHeaderRowCount[overload1]$$$setHeaderRowCountint -->
<h3 class="fn" id="setHeaderRowCount"><a name="setHeaderRowCount"></a><span class="type">void</span> QTextTableFormat::<span class="name">setHeaderRowCount</span>(<span class="type">int</span> <i>count</i>)</h3>
<p>Declares the first <i>count</i> rows of the table as table header. The table header rows get repeated when a table is broken across a page boundary.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qtexttableformat.html#headerRowCount">headerRowCount</a>().</p>
<!-- @@@setHeaderRowCount -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
